package com.gy.pinduoduo;

public class demo1 {
    public static int duoduo(int num){
        if (num>45){
            return -1;
        }
        int ans = 0, max = 9, level = 1;
        while(num > 0){
            if(num > max){
                ans += max * level;
                level *= 10;
            }else {
                ans += num *level;
            }
            num -= max;
            max--;
        }

        return ans;
    }

    public static void main(String[] args) {
        System.out.println(duoduo(5));
    }
}
